import random
import string

def actcode():
    #随机获取长度为32的片段
    a = ''.join(random.sample(string.ascii_uppercase + string.digits,32))
    return a

def generate():
    N = input("请输入你想生成的激活码个数：")
    if N.isdigit():
        with open('actcode.txt', 'w') as f1:
            for i in range(int(N)):
                num = actcode()
                # 将生成的激活码写入文件并换行
                f1.write(num + '\n')
    else:
        print("请输入正确的数字")

generate()
